/**
 * <copyright>
 * </copyright>
 *
 */
package de.sabram.upb.specs.lido.impl;

import de.sabram.upb.specs.lido.CompPart;
import de.sabram.upb.specs.lido.LidoPackage;
import de.sabram.upb.specs.lido.Production;
import de.sabram.upb.specs.lido.RuleSpec;
import de.sabram.upb.specs.lido.RuleSpecId;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Rule Spec</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.sabram.upb.specs.lido.impl.RuleSpecImpl#getRuleSpecId <em>Rule Spec Id</em>}</li>
 *   <li>{@link de.sabram.upb.specs.lido.impl.RuleSpecImpl#getProduction <em>Production</em>}</li>
 *   <li>{@link de.sabram.upb.specs.lido.impl.RuleSpecImpl#getCompPart <em>Comp Part</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class RuleSpecImpl extends SpecificationImpl implements RuleSpec
{
  /**
   * The cached value of the '{@link #getRuleSpecId() <em>Rule Spec Id</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getRuleSpecId()
   * @generated
   * @ordered
   */
  protected RuleSpecId ruleSpecId;

  /**
   * The cached value of the '{@link #getProduction() <em>Production</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getProduction()
   * @generated
   * @ordered
   */
  protected Production production;

  /**
   * The cached value of the '{@link #getCompPart() <em>Comp Part</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getCompPart()
   * @generated
   * @ordered
   */
  protected CompPart compPart;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected RuleSpecImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return LidoPackage.Literals.RULE_SPEC;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public RuleSpecId getRuleSpecId()
  {
    return ruleSpecId;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetRuleSpecId(RuleSpecId newRuleSpecId, NotificationChain msgs)
  {
    RuleSpecId oldRuleSpecId = ruleSpecId;
    ruleSpecId = newRuleSpecId;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LidoPackage.RULE_SPEC__RULE_SPEC_ID, oldRuleSpecId, newRuleSpecId);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setRuleSpecId(RuleSpecId newRuleSpecId)
  {
    if (newRuleSpecId != ruleSpecId)
    {
      NotificationChain msgs = null;
      if (ruleSpecId != null)
        msgs = ((InternalEObject)ruleSpecId).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LidoPackage.RULE_SPEC__RULE_SPEC_ID, null, msgs);
      if (newRuleSpecId != null)
        msgs = ((InternalEObject)newRuleSpecId).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LidoPackage.RULE_SPEC__RULE_SPEC_ID, null, msgs);
      msgs = basicSetRuleSpecId(newRuleSpecId, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LidoPackage.RULE_SPEC__RULE_SPEC_ID, newRuleSpecId, newRuleSpecId));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Production getProduction()
  {
    return production;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetProduction(Production newProduction, NotificationChain msgs)
  {
    Production oldProduction = production;
    production = newProduction;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LidoPackage.RULE_SPEC__PRODUCTION, oldProduction, newProduction);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setProduction(Production newProduction)
  {
    if (newProduction != production)
    {
      NotificationChain msgs = null;
      if (production != null)
        msgs = ((InternalEObject)production).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LidoPackage.RULE_SPEC__PRODUCTION, null, msgs);
      if (newProduction != null)
        msgs = ((InternalEObject)newProduction).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LidoPackage.RULE_SPEC__PRODUCTION, null, msgs);
      msgs = basicSetProduction(newProduction, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LidoPackage.RULE_SPEC__PRODUCTION, newProduction, newProduction));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public CompPart getCompPart()
  {
    return compPart;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetCompPart(CompPart newCompPart, NotificationChain msgs)
  {
    CompPart oldCompPart = compPart;
    compPart = newCompPart;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LidoPackage.RULE_SPEC__COMP_PART, oldCompPart, newCompPart);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setCompPart(CompPart newCompPart)
  {
    if (newCompPart != compPart)
    {
      NotificationChain msgs = null;
      if (compPart != null)
        msgs = ((InternalEObject)compPart).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LidoPackage.RULE_SPEC__COMP_PART, null, msgs);
      if (newCompPart != null)
        msgs = ((InternalEObject)newCompPart).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LidoPackage.RULE_SPEC__COMP_PART, null, msgs);
      msgs = basicSetCompPart(newCompPart, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LidoPackage.RULE_SPEC__COMP_PART, newCompPart, newCompPart));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case LidoPackage.RULE_SPEC__RULE_SPEC_ID:
        return basicSetRuleSpecId(null, msgs);
      case LidoPackage.RULE_SPEC__PRODUCTION:
        return basicSetProduction(null, msgs);
      case LidoPackage.RULE_SPEC__COMP_PART:
        return basicSetCompPart(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case LidoPackage.RULE_SPEC__RULE_SPEC_ID:
        return getRuleSpecId();
      case LidoPackage.RULE_SPEC__PRODUCTION:
        return getProduction();
      case LidoPackage.RULE_SPEC__COMP_PART:
        return getCompPart();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case LidoPackage.RULE_SPEC__RULE_SPEC_ID:
        setRuleSpecId((RuleSpecId)newValue);
        return;
      case LidoPackage.RULE_SPEC__PRODUCTION:
        setProduction((Production)newValue);
        return;
      case LidoPackage.RULE_SPEC__COMP_PART:
        setCompPart((CompPart)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case LidoPackage.RULE_SPEC__RULE_SPEC_ID:
        setRuleSpecId((RuleSpecId)null);
        return;
      case LidoPackage.RULE_SPEC__PRODUCTION:
        setProduction((Production)null);
        return;
      case LidoPackage.RULE_SPEC__COMP_PART:
        setCompPart((CompPart)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case LidoPackage.RULE_SPEC__RULE_SPEC_ID:
        return ruleSpecId != null;
      case LidoPackage.RULE_SPEC__PRODUCTION:
        return production != null;
      case LidoPackage.RULE_SPEC__COMP_PART:
        return compPart != null;
    }
    return super.eIsSet(featureID);
  }

} //RuleSpecImpl
